<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>写文章页面</title>
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.7.0/themes/metro-blue/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.7.0/themes/icon.css">
    <script type="text/javascript" src="/static/jquery-easyui-1.7.0/jquery.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.7.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.7.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
    <script type="text/javascript">
        function submitData() {
            $("#fm").form("submit", {
                url: "/admin/article/save",
                onSubmit: function () {
                    var content = CKEDITOR.instances.content.getData();
                    if (content == "") {
                        $.messager.alert("系统提示", "内容不能为空!");
                        return false;
                    }
                    return $(this).form("validate");
                },
                success: function (result) {
                    var result = eval('(' + result + ')');
                    if (result.success) {
                        $.messager.alert("系统提示", "保存成功!");
                        resetValue();
                    } else {
                        $.messager.alert("系统提示", "保存失败！");
                    }
                }
            })
        }

        function resetValue() {
            $("#title").val("");
            $("#typeId").combobox("setValue", "");
            CKEDITOR.instances.content.setData("");
        }

        $(document).ready(function () {
            $("#typeId").combobox({
                mode: 'remote',
                url: '/admin/articleType/comboList',
                valueField: 'id',
                textField: 'name',
                delay: 100
            });
        });
    </script>
</head>
<body style="margin: 10px">
<div id="p" class="easyui-panel" title="写文章" style="padding: 10px;width: 1300px">
    <form action="" id="fm" method="post" enctype="multipart/form-data">
        <table cellspacing="20px">
            <tr>
                <td width="80px">文章标题：</td>
                <td>
                    <input type="text" id="title" name="title" style="width: 400px" required="true"
                           class="easyui-validatebox"/>
                </td>
            </tr>
            <tr>
                <td>所属类别：</td>
                <td>
                    <input class="easyui-combobox" id="typeId" name="typeId" style="width: 140px"
                           required="true" editable="false"
                           data-options="required:true,panelHeight:'auto',valueField:'id',textField:'name',url:'/admin/articleType/comboList'"/>
                </td>
            </tr>
            <tr>
                <td valign="top">文章内容：</td>
                <td>
                    <textarea id="content" name="content" rows="30" cols="80"></textarea>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <a href="javascript:submitData()" class="easyui-linkbutton"
                       data-options="iconCls:'icon-submit'"><strong>发布</strong></a>
                </td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript">
    CKEDITOR.replace("content");
</script>
</body>
</html>